home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / kuaqe2.zip / CLIENT.QC < prev    next >
Text File  |  1996-10-06  |  35KB  |  1,481 lines

  1.  
  2. // prototypes
  3. void () W_WeaponFrame;
  4. void() W_SetCurrentAmmo;
  5. void() player_pain;
  6. void() player_stand1;
  7. void (vector org) spawn_tfog;
  8. void (vector org, entity death_owner) spawn_tdeath;
  9. void () ChasecamNewlevel;
  10.  
  11. float    modelindex_eyes, modelindex_player;
  12.  
  13. /*
  14. =============================================================================
  15.  
  16.                 LEVEL CHANGING / INTERMISSION
  17.  
  18. =============================================================================
  19. */
  20.  
  21. float    intermission_running;
  22. float    intermission_exittime;
  23.  
  24. /*QUAKED info_intermission (1 0.5 0.5) (-16 -16 -16) (16 16 16)
  25. This is the camera point for the intermission.
  26. Use mangle instead of angle, so you can set pitch or roll as well as yaw.  'pitch roll yaw'
  27. */
  28. void() info_intermission =
  29. {
  30. };
  31.  
  32.  
  33.  
  34. void() SetChangeParms =
  35. {
  36. // remove items
  37.     self.items = self.items - (self.items & 
  38.     (IT_KEY1 | IT_KEY2 | IT_INVISIBILITY | IT_INVULNERABILITY | IT_SUIT | IT_QUAD) );
  39.  
  40. // cap super health
  41.     if (self.health > 100)
  42.         self.health = 100;
  43.     if (self.health < 50)
  44.         self.health = 50;
  45.     parm1 = self.items;
  46.     parm2 = self.health;
  47.     parm3 = self.armorvalue;
  48.     if (self.ammo_shells < 25)
  49.         parm4 = 25;
  50.     else
  51.         parm4 = self.ammo_shells;
  52.     parm5 = self.ammo_nails;
  53.     parm6 = self.ammo_rockets;
  54.     parm7 = self.ammo_cells;
  55.     parm8 = self.weapon;
  56.     parm9 = self.armortype * 100;
  57.         parm10 = self.speed;
  58. };
  59.  
  60. void(float multi) SetNewParms =
  61. {
  62.         parm1 = IT_SHOTGUN | IT_AXE;
  63.         parm2 = 100;
  64.     parm3 = 0;
  65.     parm4 = 25;
  66.     parm5 = 0;
  67.     parm6 = 0;
  68.         parm7 = 0;
  69.     parm8 = 1;
  70.     parm9 = 0;
  71.         if (multi == FALSE)
  72.           parm10 = 0;
  73. };
  74.  
  75. void() DecodeLevelParms =
  76. {
  77.     if (serverflags)
  78.     {
  79.         if (world.model == "maps/start.bsp")
  80.                         SetNewParms (FALSE);         // take away all stuff on starting new episode
  81.     }
  82.     
  83.     self.items = parm1;
  84.     self.health = parm2;
  85.     self.armorvalue = parm3;
  86.     self.ammo_shells = parm4;
  87.     self.ammo_nails = parm5;
  88.     self.ammo_rockets = parm6;
  89.     self.ammo_cells = parm7;
  90.     self.weapon = parm8;
  91.     self.armortype = parm9 * 0.01;
  92.         self.speed = parm10;
  93. };
  94.  
  95. /*
  96. ============
  97. FindIntermission
  98.  
  99. Returns the entity to view from
  100. ============
  101. */
  102. entity() FindIntermission =
  103. {
  104.     local    entity spot;
  105.     local    float cyc;
  106.  
  107. // look for info_intermission first
  108.     spot = find (world, classname, "info_intermission");
  109.     if (spot)
  110.     {    // pick a random one
  111.         cyc = random() * 4;
  112.         while (cyc > 1)
  113.         {
  114.             spot = find (spot, classname, "info_intermission");
  115.             if (!spot)
  116.                 spot = find (spot, classname, "info_intermission");
  117.             cyc = cyc - 1;
  118.         }
  119.         return spot;
  120.     }
  121.  
  122. // then look for the start position
  123.     spot = find (world, classname, "info_player_start");
  124.     if (spot)
  125.         return spot;
  126.     
  127. // testinfo_player_start is only found in regioned levels
  128.     spot = find (world, classname, "testplayerstart");
  129.     if (spot)
  130.         return spot;
  131.     
  132.     objerror ("FindIntermission: no spot");
  133. };
  134.  
  135.  
  136. string nextmap;
  137. void() GotoNextMap =
  138. {
  139.     if (cvar("samelevel"))    // if samelevel is set, stay on same level
  140.         changelevel (mapname);
  141.     else
  142.         changelevel (nextmap);
  143. };
  144.  
  145.  
  146. void() ExitIntermission =
  147. {
  148. // skip any text in deathmatch
  149.     if (deathmatch)
  150.     {
  151.         GotoNextMap ();
  152.         return;
  153.     }
  154.     
  155.     intermission_exittime = time + 1;
  156.     intermission_running = intermission_running + 1;
  157.  
  158. //
  159. // run some text if at the end of an episode
  160. //
  161.     if (intermission_running == 2)
  162.     {
  163.         if (world.model == "maps/e1m7.bsp")
  164.         {
  165.             WriteByte (MSG_ALL, SVC_CDTRACK);
  166.             WriteByte (MSG_ALL, 2);
  167.             WriteByte (MSG_ALL, 3);
  168.             if (!cvar("registered"))
  169.             {
  170.                 WriteByte (MSG_ALL, SVC_FINALE);
  171.                 WriteString (MSG_ALL, "As the corpse of the monstrous entity\nChthon sinks back into the lava whence\nit rose, you grip the Rune of Earth\nMagic tightly. Now that you have\nconquered the Dimension of the Doomed,\nrealm of Earth Magic, you are ready to\ncomplete your task in the other three\nhaunted lands of Quake. Or are you? If\nyou don't register Quake, you'll never\nknow what awaits you in the Realm of\nBlack Magic, the Netherworld, and the\nElder World!");
  172.             }
  173.             else
  174.             {
  175.                 WriteByte (MSG_ALL, SVC_FINALE);
  176.                 WriteString (MSG_ALL, "As the corpse of the monstrous entity\nChthon sinks back into the lava whence\nit rose, you grip the Rune of Earth\nMagic tightly. Now that you have\nconquered the Dimension of the Doomed,\nrealm of Earth Magic, you are ready to\ncomplete your task. A Rune of magic\npower lies at the end of each haunted\nland of Quake. Go forth, seek the\ntotality of the four Runes!");
  177.             }
  178.             return;
  179.         }
  180.         else if (world.model == "maps/e2m6.bsp")
  181.         {
  182.             WriteByte (MSG_ALL, SVC_CDTRACK);
  183.             WriteByte (MSG_ALL, 2);
  184.             WriteByte (MSG_ALL, 3);
  185.  
  186.             WriteByte (MSG_ALL, SVC_FINALE);
  187.             WriteString (MSG_ALL, "The Rune of Black Magic throbs evilly in\nyour hand and whispers dark thoughts\ninto your brain. You learn the inmost\nlore of the Hell-Mother; Shub-Niggurath!\nYou now know that she is behind all the\nterrible plotting which has led to so\nmuch death and horror. But she is not\ninviolate! Armed with this Rune, you\nrealize that once all four Runes are\ncombined, the gate to Shub-Niggurath's\nPit will open, and you can face the\nWitch-Goddess herself in her frightful\notherworld cathedral.");
  188.             return;
  189.         }
  190.         else if (world.model == "maps/e3m6.bsp")
  191.         {
  192.             WriteByte (MSG_ALL, SVC_CDTRACK);
  193.             WriteByte (MSG_ALL, 2);
  194.             WriteByte (MSG_ALL, 3);
  195.  
  196.             WriteByte (MSG_ALL, SVC_FINALE);
  197.             WriteString (MSG_ALL, "The charred viscera of diabolic horrors\nbubble viscously as you seize the Rune\nof Hell Magic. Its heat scorches your\nhand, and its terrible secrets blight\nyour mind. Gathering the shreds of your\ncourage, you shake the devil's shackles\nfrom your soul, and become ever more\nhard and determined to destroy the\nhideous creatures whose mere existence\nthreatens the souls and psyches of all\nthe population of Earth.");
  198.             return;
  199.         }
  200.         else if (world.model == "maps/e4m7.bsp")
  201.         {
  202.             WriteByte (MSG_ALL, SVC_CDTRACK);
  203.             WriteByte (MSG_ALL, 2);
  204.             WriteByte (MSG_ALL, 3);
  205.  
  206.             WriteByte (MSG_ALL, SVC_FINALE);
  207.             WriteString (MSG_ALL, "Despite the awful might of the Elder\nWorld, you have achieved the Rune of\nElder Magic, capstone of all types of\narcane wisdom. Beyond good and evil,\nbeyond life and death, the Rune\npulsates, heavy with import. Patient and\npotent, the Elder Being Shub-Niggurath\nweaves her dire plans to clear off all\nlife from the Earth, and bring her own\nfoul offspring to our world! For all the\ndwellers in these nightmare dimensions\nare her descendants! Once all Runes of\nmagic power are united, the energy\nbehind them will blast open the Gateway\nto Shub-Niggurath, and you can travel\nthere to foil the Hell-Mother's plots\nin person.");
  208.             return;
  209.         }
  210.  
  211.         GotoNextMap();
  212.     }
  213.     
  214.     if (intermission_running == 3)
  215.     {
  216.         if (!cvar("registered"))
  217.         {    // shareware episode has been completed, go to sell screen
  218.             WriteByte (MSG_ALL, SVC_SELLSCREEN);
  219.             return;
  220.         }
  221.         
  222.         if ( (serverflags&15) == 15)
  223.         {
  224.             WriteByte (MSG_ALL, SVC_FINALE);
  225.             WriteString (MSG_ALL, "Now, you have all four Runes. You sense\ntremendous invisible forces moving to\nunseal ancient barriers. Shub-Niggurath\nhad hoped to use the Runes Herself to\nclear off the Earth, but now instead,\nyou will use them to enter her home and\nconfront her as an avatar of avenging\nEarth-life. If you defeat her, you will\nbe remembered forever as the savior of\nthe planet. If she conquers, it will be\nas if you had never been born.");
  226.             return;
  227.         }
  228.         
  229.     }
  230.  
  231.     GotoNextMap();
  232. };
  233.  
  234. /*
  235. ============
  236. IntermissionThink
  237.  
  238. When the player presses attack or jump, change to the next level
  239. ============
  240. */
  241. void() IntermissionThink =
  242. {
  243. //      if (time < intermission_exittime)
  244. //              return;
  245.  
  246.     if (!self.button0 && !self.button1 && !self.button2)
  247.         return;
  248.     
  249.     ExitIntermission ();
  250. };
  251.  
  252. void() execute_changelevel =
  253. {
  254.     local entity    pos;
  255.  
  256.     intermission_running = 1;
  257.     
  258. // enforce a wait time before allowing changelevel
  259.     if (deathmatch)
  260.         intermission_exittime = time + 5;
  261.     else
  262.         intermission_exittime = time + 2;
  263.  
  264.     WriteByte (MSG_ALL, SVC_CDTRACK);
  265.     WriteByte (MSG_ALL, 3);
  266.     WriteByte (MSG_ALL, 3);
  267.     
  268.     pos = FindIntermission ();
  269.  
  270.     other = find (world, classname, "player");
  271.     while (other != world)
  272.     {
  273.         other.view_ofs = '0 0 0';
  274.         other.angles = other.v_angle = pos.mangle;
  275.         other.fixangle = TRUE;        // turn this way immediately
  276.         other.nextthink = time + 0.5;
  277.         other.takedamage = DAMAGE_NO;
  278.         other.solid = SOLID_NOT;
  279.         other.movetype = MOVETYPE_NONE;
  280.         other.modelindex = 0;
  281.         setorigin (other, pos.origin);
  282.         other = find (other, classname, "player");
  283.     }    
  284.  
  285.     WriteByte (MSG_ALL, SVC_INTERMISSION);
  286. };
  287.  
  288.  
  289. void() changelevel_touch =
  290. {
  291.     local entity    pos;
  292.  
  293.     if (other.classname != "player")
  294.         return;
  295.  
  296.     if (cvar("noexit"))
  297.     {
  298.         T_Damage (other, self, self, 50000);
  299.         return;
  300.     }
  301.     bprint (other.netname);
  302.     bprint (" exited the level\n");
  303.  
  304.     nextmap = self.map;
  305.  
  306.     SUB_UseTargets ();
  307.  
  308.     if ( (self.spawnflags & 1) && (deathmatch == 0) )
  309.     {    // NO_INTERMISSION
  310.         GotoNextMap();
  311.         return;
  312.     }
  313.     
  314.     self.touch = SUB_Null;
  315.  
  316. // we can't move people right now, because touch functions are called
  317. // in the middle of C movement code, so set a think time to do it
  318.     self.think = execute_changelevel;
  319.     self.nextthink = time + 0.1;
  320. };
  321.  
  322. /*QUAKED trigger_changelevel (0.5 0.5 0.5) ? NO_INTERMISSION
  323. When the player touches this, he gets sent to the map listed in the "map" variable.  Unless the NO_INTERMISSION flag is set, the view will go to the info_intermission spot and display stats.
  324. */
  325. void() trigger_changelevel =
  326. {
  327.     if (!self.map)
  328.         objerror ("chagnelevel trigger doesn't have map");
  329.     
  330.     InitTrigger ();
  331.     self.touch = changelevel_touch;
  332. };
  333.  
  334.  
  335. /*
  336. =============================================================================
  337.  
  338.                 PLAYER GAME EDGE FUNCTIONS
  339.  
  340. =============================================================================
  341. */
  342.  
  343. void() set_suicide_frame;
  344.  
  345. // called by ClientKill and DeadThink
  346. void() respawn =
  347. {
  348.     if (coop)
  349.     {
  350.         // make a copy of the dead body for appearances sake
  351.         CopyToBodyQue (self);
  352.         // get the spawn parms as they were at level start
  353.         setspawnparms (self);
  354.         // respawn        
  355.         PutClientInServer ();
  356.     }
  357.     else if (deathmatch)
  358.     {
  359.         // make a copy of the dead body for appearances sake
  360.         CopyToBodyQue (self);
  361.         // set default spawn parms
  362.                 SetNewParms (TRUE);
  363.         // respawn        
  364.         PutClientInServer ();
  365.     }
  366.     else
  367.     {    // restart the entire server
  368.         localcmd ("restart\n");
  369.     }
  370. };
  371.  
  372.  
  373. /*
  374. ============
  375. ClientKill
  376.  
  377. Player entered the suicide command
  378. ============
  379. */
  380. void() ClientKill =
  381. {
  382.     bprint (self.netname);
  383.     bprint (" suicides\n");
  384.     set_suicide_frame ();
  385.     self.modelindex = modelindex_player;
  386.     self.frags = self.frags - 2;    // extra penalty
  387.     respawn ();
  388. };
  389.  
  390. float(vector v) CheckSpawnPoint =
  391. {
  392.     return FALSE;
  393. };
  394.  
  395. /*
  396. ============
  397. SelectSpawnPoint
  398.  
  399. Returns the entity to spawn at
  400. ============
  401. */
  402. entity() SelectSpawnPoint =
  403. {
  404.     local    entity spot;
  405.     
  406. // testinfo_player_start is only found in regioned levels
  407.     spot = find (world, classname, "testplayerstart");
  408.     if (spot)
  409.         return spot;
  410.         
  411. // choose a info_player_deathmatch point
  412.     if (coop)
  413.     {
  414.         lastspawn = find(lastspawn, classname, "info_player_coop");
  415.         if (lastspawn == world)
  416.             lastspawn = find (lastspawn, classname, "info_player_start");
  417.         if (lastspawn != world)
  418.             return lastspawn;
  419.     }
  420.     else if (deathmatch)
  421.     {
  422.         lastspawn = find(lastspawn, classname, "info_player_deathmatch");
  423.         if (lastspawn == world)
  424.             lastspawn = find (lastspawn, classname, "info_player_deathmatch");
  425.         if (lastspawn != world)
  426.             return lastspawn;
  427.     }
  428.  
  429.     if (serverflags)
  430.     {    // return with a rune to start
  431.         spot = find (world, classname, "info_player_start2");
  432.         if (spot)
  433.             return spot;
  434.     }
  435.     
  436.     spot = find (world, classname, "info_player_start");
  437.     if (!spot)
  438.         error ("PutClientInServer: no info_player_start on level");
  439.     
  440.     return spot;
  441. };
  442.  
  443. /*
  444. ===========
  445. PutClientInServer
  446.  
  447. called each time a player is spawned
  448. ============
  449. */
  450. void() DecodeLevelParms;
  451. void() PlayerDie;
  452.  
  453.  
  454. void() PutClientInServer =
  455. {
  456.         local   entity spot,
  457.                        thinker;
  458.  
  459.     self.classname = "player";
  460.     self.health = 100;
  461.     self.takedamage = DAMAGE_AIM;
  462.     self.solid = SOLID_SLIDEBOX;
  463.     self.movetype = MOVETYPE_WALK;
  464.     self.show_hostile = 0;
  465.     self.max_health = 100;
  466.     self.flags = FL_CLIENT;
  467.     self.air_finished = time + 12;
  468.     self.dmg = 2;           // initial water damage
  469.     self.super_damage_finished = 0;
  470.     self.radsuit_finished = 0;
  471.     self.invisible_finished = 0;
  472.     self.invincible_finished = 0;
  473.     self.effects = 0;
  474.     self.invincible_time = 0;
  475.         self.onfire = 0;
  476.  
  477.     DecodeLevelParms ();
  478.     
  479.     W_SetCurrentAmmo ();
  480.  
  481.     self.attack_finished = time;
  482.     self.th_pain = player_pain;
  483.     self.th_die = PlayerDie;
  484.     
  485.     self.deadflag = DEAD_NO;
  486. // paustime is set by teleporters to keep the player from moving a while
  487.     self.pausetime = 0;
  488.     
  489.     spot = SelectSpawnPoint ();
  490.  
  491.     self.origin = spot.origin + '0 0 1';
  492.     self.angles = spot.angles;
  493.     self.fixangle = TRUE;        // turn this way immediately
  494.  
  495. // oh, this is a hack!
  496.     setmodel (self, "progs/eyes.mdl");
  497.     modelindex_eyes = self.modelindex;
  498.  
  499.     setmodel (self, "progs/player.mdl");
  500.     modelindex_player = self.modelindex;
  501.  
  502.     setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
  503.     
  504.     self.view_ofs = '0 0 22';
  505.  
  506.     player_stand1 ();
  507.     
  508.     if (deathmatch || coop)
  509.     {
  510.         makevectors(self.angles);
  511.         spawn_tfog (self.origin + v_forward*20);
  512.     }
  513.  
  514.     spawn_tdeath (self.origin, self);
  515.  
  516.         // Added for ChaseCam
  517.         thinker = spawn ();
  518.         thinker.owner = self;
  519.         thinker.movetype = MOVETYPE_NONE;
  520.         thinker.solid = SOLID_NOT;
  521.         setmodel (thinker, "");
  522.         setsize (thinker, VEC_ORIGIN, VEC_ORIGIN);
  523.         setorigin (thinker, thinker.owner.origin);
  524.         thinker.think = ChasecamNewlevel;
  525.         thinker.nextthink = time + 0.2;
  526. };
  527.  
  528.  
  529. /*
  530. =============================================================================
  531.  
  532.                 QUAKED FUNCTIONS
  533.  
  534. =============================================================================
  535. */
  536.  
  537.  
  538. /*QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 24)
  539. The normal starting point for a level.
  540. */
  541. void() info_player_start =
  542. {
  543. };
  544.  
  545.  
  546. /*QUAKED info_player_start2 (1 0 0) (-16 -16 -24) (16 16 24)
  547. Only used on start map for the return point from an episode.
  548. */
  549. void() info_player_start2 =
  550. {
  551. };
  552.  
  553.  
  554. /*
  555. saved out by quaked in region mode
  556. */
  557. void() testplayerstart =
  558. {
  559. };
  560.  
  561. /*QUAKED info_player_deathmatch (1 0 1) (-16 -16 -24) (16 16 24)
  562. potential spawning position for deathmatch games
  563. */
  564. void() info_player_deathmatch =
  565. {
  566. };
  567.  
  568. /*QUAKED info_player_coop (1 0 1) (-16 -16 -24) (16 16 24)
  569. potential spawning position for coop games
  570. */
  571. void() info_player_coop =
  572. {
  573. };
  574.  
  575. /*
  576. ===============================================================================
  577.  
  578. RULES
  579.  
  580. ===============================================================================
  581. */
  582.  
  583. void(entity c) PrintClientScore =
  584. {
  585.     if (c.frags > -10 && c.frags < 0)
  586.         bprint (" ");
  587.     else if (c.frags >= 0)
  588.     {
  589.         if (c.frags < 100)
  590.             bprint (" ");
  591.         if (c.frags < 10)
  592.             bprint (" ");
  593.     }
  594.     bprint (ftos(c.frags));
  595.     bprint (" ");
  596.     bprint (c.netname);
  597.     bprint ("\n");
  598. };
  599.  
  600. void() DumpScore =
  601. {
  602.     local entity    e, sort, walk;
  603.  
  604.     if (world.chain)
  605.         error ("DumpScore: world.chain is set");
  606.  
  607. // build a sorted lis
  608.     e = find(world, classname, "player");
  609.     sort = world;
  610.     while (e)
  611.     {
  612.         if (!sort)
  613.         {
  614.             sort = e;
  615.             e.chain = world;
  616.         }
  617.         else
  618.         {
  619.             if (e.frags > sort.frags)
  620.             {
  621.                 e.chain = sort;
  622.                 sort = e;
  623.             }
  624.             else
  625.             {
  626.                 walk = sort;
  627.                 do
  628.                 {
  629.                     if (!walk.chain)
  630.                     {
  631.                         e.chain = world;
  632.                         walk.chain = e;
  633.                     }
  634.                     else if (walk.chain.frags < e.frags)
  635.                     {
  636.                         e.chain = walk.chain;
  637.                         walk.chain = e;
  638.                     }
  639.                     else
  640.                         walk = walk.chain;
  641.                 } while (walk.chain != e);
  642.             }
  643.         }
  644.         
  645.         e = find(e, classname, "player");
  646.     }
  647.  
  648. // print the list
  649.     
  650.     bprint ("\n");    
  651.     while (sort)
  652.     {
  653.         PrintClientScore (sort);
  654.         sort = sort.chain;
  655.     }
  656.     bprint ("\n");
  657. };
  658.  
  659. /*
  660. go to the next level for deathmatch
  661. */
  662. void() NextLevel =
  663. {
  664.     local entity o;
  665.  
  666. // find a trigger changelevel
  667.     o = find(world, classname, "trigger_changelevel");
  668.     if (!o || mapname == "start")
  669.     {    // go back to same map if no trigger_changelevel
  670.         o = spawn();
  671.         o.map = mapname;
  672.     }
  673.  
  674.     nextmap = o.map;
  675.     
  676.     if (o.nextthink < time)
  677.     {
  678.         o.think = execute_changelevel;
  679.         o.nextthink = time + 0.1;
  680.     }
  681. };
  682.  
  683. /*
  684. ============
  685. CheckRules
  686.  
  687. Exit deathmatch games upon conditions
  688. ============
  689. */
  690. void() CheckRules =
  691. {
  692.     local    float        timelimit;
  693.     local    float        fraglimit;
  694.     
  695.     if (gameover)    // someone else quit the game already
  696.         return;
  697.         
  698.     timelimit = cvar("timelimit") * 60;
  699.     fraglimit = cvar("fraglimit");
  700.     
  701.     if (timelimit && time >= timelimit)
  702.     {
  703. NextLevel ();
  704. /*
  705.         gameover = TRUE;
  706.         bprint ("\n\n\n==============================\n");
  707.         bprint ("game exited after ");
  708.         bprint (ftos(timelimit/60));
  709.         bprint (" minutes\n");
  710.         DumpScore ();
  711.         localcmd ("killserver\n");
  712. */
  713.         return;
  714.     }
  715.     
  716.     if (fraglimit && self.frags >= fraglimit)
  717.     {
  718. NextLevel ();
  719. /*
  720.         gameover = TRUE;
  721.         bprint ("\n\n\n==============================\n");
  722.         bprint ("game exited after ");
  723.         bprint (ftos(self.frags));
  724.         bprint (" frags\n");
  725.         DumpScore ();
  726.         localcmd ("killserver\n");
  727. */
  728.         return;
  729.     }    
  730. };
  731.  
  732. //============================================================================
  733.  
  734. void() PlayerDeathThink =
  735. {
  736.     local entity    old_self;
  737.     local float        forward;
  738.  
  739.     if ((self.flags & FL_ONGROUND))
  740.     {
  741.         forward = vlen (self.velocity);
  742.         forward = forward - 20;
  743.         if (forward <= 0)
  744.             self.velocity = '0 0 0';
  745.         else    
  746.             self.velocity = forward * normalize(self.velocity);
  747.     }
  748.  
  749. // wait for all buttons released
  750.     if (self.deadflag == DEAD_DEAD)
  751.     {
  752.         if (self.button2 || self.button1 || self.button0)
  753.             return;
  754.         self.deadflag = DEAD_RESPAWNABLE;
  755.         return;
  756.     }
  757.  
  758. // wait for any button down
  759.     if (!self.button2 && !self.button1 && !self.button0)
  760.         return;
  761.  
  762.     self.button0 = 0;
  763.     self.button1 = 0;
  764.     self.button2 = 0;
  765.     respawn();
  766. };
  767.  
  768.  
  769. void() PlayerJump =
  770. {
  771.     local vector start, end;
  772.     
  773.     if (self.flags & FL_WATERJUMP)
  774.         return;
  775.     
  776.     if (self.waterlevel >= 2)
  777.     {
  778.         if (self.watertype == CONTENT_WATER)
  779.             self.velocity_z = 100;
  780.         else if (self.watertype == CONTENT_SLIME)
  781.             self.velocity_z = 80;
  782.         else
  783.             self.velocity_z = 50;
  784.  
  785. // play swiming sound
  786.         if (self.swim_flag < time)
  787.         {
  788.             self.swim_flag = time + 1;
  789.             if (random() < 0.5)
  790.                 sound (self, CHAN_BODY, "misc/water1.wav", 1, ATTN_NORM);
  791.             else
  792.                 sound (self, CHAN_BODY, "misc/water2.wav", 1, ATTN_NORM);
  793.         }
  794.  
  795.         return;
  796.     }
  797.  
  798.     if (!(self.flags & FL_ONGROUND))
  799.         return;
  800.  
  801.     if ( !(self.flags & FL_JUMPRELEASED) )
  802.         return;        // don't pogo stick
  803.  
  804.     self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
  805.  
  806.     self.flags = self.flags - FL_ONGROUND;    // don't stairwalk
  807.     
  808.     self.button2 = 0;
  809. // player jumping sound
  810.     sound (self, CHAN_BODY, "player/plyrjmp8.wav", 1, ATTN_NORM);
  811.     self.velocity_z = self.velocity_z + 270;
  812. };
  813.  
  814.  
  815. /*
  816. ===========
  817. WaterMove
  818.  
  819. ============
  820. */
  821. .float    dmgtime;
  822.  
  823. void() WaterMove =
  824. {
  825. //dprint (ftos(self.waterlevel));
  826.     if (self.movetype == MOVETYPE_NOCLIP)
  827.         return;
  828.     if (self.health < 0)
  829.         return;
  830.  
  831.     if (self.waterlevel != 3)
  832.     {
  833.         if (self.air_finished < time)
  834.             sound (self, CHAN_VOICE, "player/gasp2.wav", 1, ATTN_NORM);
  835.         else if (self.air_finished < time + 9)
  836.             sound (self, CHAN_VOICE, "player/gasp1.wav", 1, ATTN_NORM);
  837.         self.air_finished = time + 12;
  838.         self.dmg = 2;
  839.     }
  840.     else if (self.air_finished < time)
  841.     {    // drown!
  842.         if (self.pain_finished < time)
  843.         {
  844.             self.dmg = self.dmg + 2;
  845.             if (self.dmg > 15)
  846.                 self.dmg = 10;
  847.             T_Damage (self, world, world, self.dmg);
  848.             self.pain_finished = time + 1;
  849.         }
  850.     }
  851.     
  852.     if (!self.waterlevel)
  853.     {
  854.         if (self.flags & FL_INWATER)
  855.         {    
  856.             // play leave water sound
  857.             sound (self, CHAN_BODY, "misc/outwater.wav", 1, ATTN_NORM);
  858.             self.flags = self.flags - FL_INWATER;
  859.         }
  860.         return;
  861.     }
  862.  
  863.     if (self.watertype == CONTENT_LAVA)
  864.     {    // do damage
  865.         if (self.dmgtime < time)
  866.         {
  867.             if (self.radsuit_finished > time)
  868.                 self.dmgtime = time + 1;
  869.             else
  870.                 self.dmgtime = time + 0.2;
  871.  
  872.             T_Damage (self, world, world, 10*self.waterlevel);
  873.         }
  874.     }
  875.     else if (self.watertype == CONTENT_SLIME)
  876.     {    // do damage
  877.         if (self.dmgtime < time && self.radsuit_finished < time)
  878.         {
  879.             self.dmgtime = time + 1;
  880.             T_Damage (self, world, world, 4*self.waterlevel);
  881.         }
  882.     }
  883.     
  884.     if ( !(self.flags & FL_INWATER) )
  885.     {    
  886.  
  887. // player enter water sound
  888.  
  889.         if (self.watertype == CONTENT_LAVA)
  890.             sound (self, CHAN_BODY, "player/inlava.wav", 1, ATTN_NORM);
  891.         if (self.watertype == CONTENT_WATER)
  892.             sound (self, CHAN_BODY, "player/inh2o.wav", 1, ATTN_NORM);
  893.         if (self.watertype == CONTENT_SLIME)
  894.             sound (self, CHAN_BODY, "player/slimbrn2.wav", 1, ATTN_NORM);
  895.  
  896.         self.flags = self.flags + FL_INWATER;
  897.         self.dmgtime = 0;
  898.     }
  899.     
  900.     if (! (self.flags & FL_WATERJUMP) )
  901.         self.velocity = self.velocity - 0.8*self.waterlevel*frametime*self.velocity;
  902. };
  903.  
  904. void() CheckWaterJump =
  905. {
  906.     local vector start, end;
  907.  
  908. // check for a jump-out-of-water
  909.     makevectors (self.angles);
  910.     start = self.origin;
  911.     start_z = start_z + 8; 
  912.     v_forward_z = 0;
  913.     normalize(v_forward);
  914.     end = start + v_forward*24;
  915.     traceline (start, end, TRUE, self);
  916.     if (trace_fraction < 1)
  917.     {    // solid at waist
  918.         start_z = start_z + self.maxs_z - 8;
  919.         end = start + v_forward*24;
  920.         self.movedir = trace_plane_normal * -50;
  921.         traceline (start, end, TRUE, self);
  922.         if (trace_fraction == 1)
  923.         {    // open at eye level
  924.             self.flags = self.flags | FL_WATERJUMP;
  925.             self.velocity_z = 225;
  926.             self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
  927.             self.teleport_time = time + 2;    // safety net
  928.             return;
  929.         }
  930.     }
  931. };
  932.  
  933.  
  934. /*
  935. ================
  936. PlayerPreThink
  937.  
  938. Called every frame before physics are run
  939. ================
  940. */
  941. void() PlayerPreThink =
  942. {
  943.     local    float    mspeed, aspeed;
  944.     local    float    r;
  945.  
  946.     if (intermission_running)
  947.     {
  948.         IntermissionThink ();    // otherwise a button could be missed between
  949.         return;                    // the think tics
  950.     }
  951.  
  952.     if (self.view_ofs == '0 0 0')
  953.         return;        // intermission or finale
  954.  
  955.     makevectors (self.v_angle);        // is this still used
  956.  
  957.     CheckRules ();
  958.     WaterMove ();
  959.  
  960.     if (self.waterlevel == 2)
  961.         CheckWaterJump ();
  962.  
  963.     if (self.deadflag >= DEAD_DEAD)
  964.     {
  965.         PlayerDeathThink ();
  966.         return;
  967.     }
  968.     
  969.     if (self.deadflag == DEAD_DYING)
  970.         return;    // dying, so do nothing
  971.  
  972.     if (self.button2)
  973.     {
  974.         PlayerJump ();
  975.     }
  976.     else
  977.         self.flags = self.flags | FL_JUMPRELEASED;
  978.  
  979. // teleporters can force a non-moving pause time    
  980.     if (time < self.pausetime)
  981.         self.velocity = '0 0 0';
  982. };
  983.     
  984. /*
  985. ================
  986. CheckPowerups
  987.  
  988. Check for turning off powerups
  989. ================
  990. */
  991. void() CheckPowerups =
  992. {
  993.     if (self.health <= 0)
  994.         return;
  995.  
  996. // invisibility
  997.     if (self.invisible_finished)
  998.     {
  999. // sound and screen flash when items starts to run out
  1000.         if (self.invisible_sound < time)
  1001.         {
  1002.             sound (self, CHAN_AUTO, "items/inv3.wav", 0.5, ATTN_IDLE);
  1003.             self.invisible_sound = time + ((random() * 3) + 1);
  1004.         }
  1005.  
  1006.  
  1007.         if (self.invisible_finished < time + 3)
  1008.         {
  1009.             if (self.invisible_time == 1)
  1010.             {
  1011.                 sprint (self, "Ring of Shadows magic is fading\n");
  1012.                 stuffcmd (self, "bf\n");
  1013.                 sound (self, CHAN_AUTO, "items/inv2.wav", 1, ATTN_NORM);
  1014.                 self.invisible_time = time + 1;
  1015.             }
  1016.             
  1017.             if (self.invisible_time < time)
  1018.             {
  1019.                 self.invisible_time = time + 1;
  1020.                 stuffcmd (self, "bf\n");
  1021.             }
  1022.         }
  1023.  
  1024.         if (self.invisible_finished < time)
  1025.         {    // just stopped
  1026.             self.items = self.items - IT_INVISIBILITY;
  1027.             self.invisible_finished = 0;
  1028.             self.invisible_time = 0;
  1029.         }
  1030.         
  1031.     // use the eyes
  1032.         self.frame = 0;
  1033.         self.modelindex = modelindex_eyes;
  1034.     }
  1035.     else
  1036.         self.modelindex = modelindex_player;    // don't use eyes
  1037.  
  1038. // invincibility
  1039.     if (self.invincible_finished)
  1040.     {
  1041. // sound and screen flash when items starts to run out
  1042.         if (self.invincible_finished < time + 3)
  1043.         {
  1044.             if (self.invincible_time == 1)
  1045.             {
  1046.                 sprint (self, "Protection is almost burned out\n");
  1047.                 stuffcmd (self, "bf\n");
  1048.                 sound (self, CHAN_AUTO, "items/protect2.wav", 1, ATTN_NORM);
  1049.                 self.invincible_time = time + 1;
  1050.             }
  1051.             
  1052.             if (self.invincible_time < time)
  1053.             {
  1054.                 self.invincible_time = time + 1;
  1055.                 stuffcmd (self, "bf\n");
  1056.             }
  1057.         }
  1058.         
  1059.         if (self.invincible_finished < time)
  1060.         {    // just stopped
  1061.             self.items = self.items - IT_INVULNERABILITY;
  1062.             self.invincible_time = 0;
  1063.             self.invincible_finished = 0;
  1064.         }
  1065.         if (self.invincible_finished > time)
  1066.             self.effects = self.effects | EF_DIMLIGHT;
  1067.         else
  1068.             self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  1069.     }
  1070.  
  1071. // super damage
  1072.     if (self.super_damage_finished)
  1073.     {
  1074.  
  1075. // sound and screen flash when items starts to run out
  1076.  
  1077.         if (self.super_damage_finished < time + 3)
  1078.         {
  1079.             if (self.super_time == 1)
  1080.             {
  1081.                 sprint (self, "Quad Damage is wearing off\n");
  1082.                 stuffcmd (self, "bf\n");
  1083.                 sound (self, CHAN_AUTO, "items/damage2.wav", 1, ATTN_NORM);
  1084.                 self.super_time = time + 1;
  1085.             }      
  1086.             
  1087.             if (self.super_time < time)
  1088.             {
  1089.                 self.super_time = time + 1;
  1090.                 stuffcmd (self, "bf\n");
  1091.             }
  1092.         }
  1093.  
  1094.         if (self.super_damage_finished < time)
  1095.         {    // just stopped
  1096.             self.items = self.items - IT_QUAD;
  1097.             self.super_damage_finished = 0;
  1098.             self.super_time = 0;
  1099.         }
  1100.         if (self.super_damage_finished > time)
  1101.             self.effects = self.effects | EF_DIMLIGHT;
  1102.         else
  1103.             self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  1104.     }    
  1105.  
  1106. // suit    
  1107.     if (self.radsuit_finished)
  1108.     {
  1109.         self.air_finished = time + 12;        // don't drown
  1110.  
  1111. // sound and screen flash when items starts to run out
  1112.         if (self.radsuit_finished < time + 3)
  1113.         {
  1114.             if (self.rad_time == 1)
  1115.             {
  1116.                 sprint (self, "Air supply in Biosuit expiring\n");
  1117.                 stuffcmd (self, "bf\n");
  1118.                 sound (self, CHAN_AUTO, "items/suit2.wav", 1, ATTN_NORM);
  1119.                 self.rad_time = time + 1;
  1120.             }
  1121.             
  1122.             if (self.rad_time < time)
  1123.             {
  1124.                 self.rad_time = time + 1;
  1125.                 stuffcmd (self, "bf\n");
  1126.             }
  1127.         }
  1128.  
  1129.         if (self.radsuit_finished < time)
  1130.         {    // just stopped
  1131.             self.items = self.items - IT_SUIT;
  1132.             self.rad_time = 0;
  1133.             self.radsuit_finished = 0;
  1134.         }
  1135.     }    
  1136.  
  1137. };
  1138.  
  1139.  
  1140. /*
  1141. ================
  1142. PlayerPostThink
  1143.  
  1144. Called every frame after physics are run
  1145. ================
  1146. */
  1147. void() PlayerPostThink =
  1148. {
  1149.     local    float    mspeed, aspeed;
  1150.     local    float    r;
  1151.  
  1152.     if (self.view_ofs == '0 0 0')
  1153.         return;        // intermission or finale
  1154.     if (self.deadflag)
  1155.         return;
  1156.         
  1157. // do weapon stuff
  1158.  
  1159.     W_WeaponFrame ();
  1160.  
  1161. // check to see if player landed and play landing sound    
  1162.     if ((self.jump_flag < -300) && (self.flags & FL_ONGROUND) && (self.health > 0))
  1163.     {
  1164.         if (self.watertype == CONTENT_WATER)
  1165.             sound (self, CHAN_BODY, "player/h2ojump.wav", 1, ATTN_NORM);
  1166.         else if (self.jump_flag < -650)
  1167.         {
  1168.             T_Damage (self, world, world, 5); 
  1169.             sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  1170.             self.deathtype = "falling";
  1171.         }
  1172.         else
  1173.             sound (self, CHAN_VOICE, "player/land.wav", 1, ATTN_NORM);
  1174.  
  1175.         self.jump_flag = 0;
  1176.     }
  1177.  
  1178.     if (!(self.flags & FL_ONGROUND))
  1179.         self.jump_flag = self.velocity_z;
  1180.  
  1181.     CheckPowerups ();
  1182. };
  1183.  
  1184.  
  1185. /*
  1186. ===========
  1187. ClientConnect
  1188.  
  1189. called when a player connects to a server
  1190. ============
  1191. */
  1192. void() ClientConnect =
  1193. {
  1194.     bprint (self.netname);
  1195.     bprint (" entered the game\n");
  1196.     
  1197. // a client connecting during an intermission can cause problems
  1198.     if (intermission_running)
  1199.         ExitIntermission ();
  1200. };
  1201.  
  1202.  
  1203. /*
  1204. ===========
  1205. ClientDisconnect
  1206.  
  1207. called when a player disconnects from a server
  1208. ============
  1209. */
  1210. void() ClientDisconnect =
  1211. {
  1212.     if (gameover)
  1213.         return;
  1214.     // if the level end trigger has been activated, just return
  1215.     // since they aren't *really* leaving
  1216.  
  1217.     // let everyone else know
  1218.     bprint (self.netname);
  1219.     bprint (" left the game with ");
  1220.     bprint (ftos(self.frags));
  1221.     bprint (" frags\n");
  1222.     sound (self, CHAN_BODY, "player/tornoff2.wav", 1, ATTN_NONE);
  1223.     set_suicide_frame ();
  1224. };
  1225.  
  1226. /*
  1227. ===========
  1228. ClientObituary
  1229.  
  1230. called when a player dies
  1231. ============
  1232. */
  1233. void(entity targ, entity attacker) ClientObituary =
  1234. {
  1235.     local    float rnum;
  1236.     local    string deathstring, deathstring2;
  1237.     rnum = random();
  1238.  
  1239.     if (targ.classname == "player")
  1240.     {
  1241.         if (attacker.classname == "teledeath")
  1242.         {
  1243.             bprint (targ.netname);
  1244.             bprint (" was telefragged by ");
  1245.             bprint (attacker.owner.netname);
  1246.             bprint ("\n");
  1247.  
  1248.             attacker.owner.frags = attacker.owner.frags + 1;
  1249.             return;
  1250.         }
  1251.  
  1252.         if (attacker.classname == "teledeath2")
  1253.         {
  1254.             bprint ("Satan's power deflects ");
  1255.             bprint (targ.netname);
  1256.             bprint ("'s telefrag\n");
  1257.  
  1258.             targ.frags = targ.frags - 1;
  1259.             return;
  1260.         }
  1261.  
  1262.         if (attacker.classname == "player")
  1263.         {
  1264.             if (targ == attacker)
  1265.             {
  1266.                 // killed self
  1267.                 attacker.frags = attacker.frags - 1;
  1268.                 bprint (targ.netname);
  1269.                 
  1270.                 if (targ.weapon == 64 && targ.waterlevel > 1)
  1271.                 {
  1272.                     bprint (" discharges into the water.\n");
  1273.                     return;
  1274.                 }
  1275.                 if (targ.weapon == 16)
  1276.                     bprint (" tries to put the pin back in\n");
  1277.                 else if (rnum)
  1278.                     bprint (" becomes bored with life\n");
  1279.                 else
  1280.                     bprint (" checks if his weapon is loaded\n");
  1281.                 return;
  1282.             }
  1283.             else
  1284.             {
  1285.                 attacker.frags = attacker.frags + 1;
  1286.  
  1287.                 rnum = attacker.weapon;
  1288.                 if (rnum == IT_AXE)
  1289.                 {
  1290.                     deathstring = " was ax-murdered by ";
  1291.                     deathstring2 = "\n";
  1292.                 }
  1293.                 if (rnum == IT_SHOTGUN)
  1294.                 {
  1295.                     deathstring = " chewed on ";
  1296.                     deathstring2 = "'s boomstick\n";
  1297.                 }
  1298.                 if (rnum == IT_SUPER_SHOTGUN)
  1299.                 {
  1300.                     deathstring = " ate 2 loads of ";
  1301.                     deathstring2 = "'s buckshot\n";
  1302.                 }
  1303.                 if (rnum == IT_NAILGUN)
  1304.                 {
  1305.                     deathstring = " was nailed by ";
  1306.                     deathstring2 = "\n";
  1307.                 }
  1308.                 if (rnum == IT_SUPER_NAILGUN)
  1309.                 {
  1310.                     deathstring = " was punctured by ";
  1311.                     deathstring2 = "\n";
  1312.                 }
  1313.                 if (rnum == IT_GRENADE_LAUNCHER)
  1314.                 {
  1315.                     deathstring = " eats ";
  1316.                     deathstring2 = "'s pineapple\n";
  1317.                     if (targ.health < -40)
  1318.                     {
  1319.                         deathstring = " was gibbed by ";
  1320.                         deathstring2 = "'s grenade\n";
  1321.                     }
  1322.                 }
  1323.                 if (rnum == IT_ROCKET_LAUNCHER)
  1324.                 {
  1325.                     deathstring = " rides ";
  1326.                     deathstring2 = "'s rocket\n";
  1327.                     if (targ.health < -40)
  1328.                     {
  1329.                         deathstring = " was gibbed by ";
  1330.                         deathstring2 = "'s rocket\n" ;
  1331.                     }
  1332.                 }
  1333.                 if (rnum == IT_LIGHTNING)
  1334.                 {
  1335.                     deathstring = " accepts ";
  1336.                     if (attacker.waterlevel > 1)
  1337.                         deathstring2 = "'s discharge\n";
  1338.                     else
  1339.                         deathstring2 = "'s shaft\n";
  1340.                 }
  1341.                                 if (rnum == IT_FLAMETHROWER)
  1342.                                 {
  1343.                                         deathstring = " is invited to ";
  1344.                                         deathstring2 = "'s barbecue\n";
  1345.                                 }
  1346.                                 if (rnum == IT_MORNINGSTAR)
  1347.                                 {
  1348.                                         deathstring = " got a whiff of ";
  1349.                                         deathstring2 = "'s morning breath\n";
  1350.                                 }
  1351.                                 bprint (targ.netname);
  1352.                 bprint (deathstring);
  1353.                 bprint (attacker.netname);
  1354.                 bprint (deathstring2);
  1355.             }
  1356.             return;
  1357.         }
  1358.         else
  1359.         {
  1360.             targ.frags = targ.frags - 1;        // killed self
  1361.             rnum = targ.watertype;
  1362.  
  1363.             bprint (targ.netname);
  1364.             if (rnum == -3)
  1365.             {
  1366.                 if (random() < 0.5)
  1367.                     bprint (" sleeps with the fishes\n");
  1368.                 else
  1369.                     bprint (" sucks it down\n");
  1370.                 return;
  1371.             }
  1372.             else if (rnum == -4)
  1373.             {
  1374.                 if (random() < 0.5)
  1375.                     bprint (" gulped a load of slime\n");
  1376.                 else
  1377.                     bprint (" can't exist on slime alone\n");
  1378.                 return;
  1379.             }
  1380.             else if (rnum == -5)
  1381.             {
  1382.                 if (targ.health < -15)
  1383.                 {
  1384.                     bprint (" burst into flames\n");
  1385.                     return;
  1386.                 }
  1387.                 if (random() < 0.5)
  1388.                     bprint (" turned into hot slag\n");
  1389.                 else
  1390.                     bprint (" visits the Volcano God\n");
  1391.                 return;
  1392.             }
  1393.  
  1394.             if (attacker.flags & FL_MONSTER)
  1395.             {
  1396.                 if (attacker.classname == "monster_army")
  1397.                     bprint (" was shot by a Grunt\n");
  1398.                 if (attacker.classname == "monster_demon1")
  1399.                     bprint (" was eviscerated by a Fiend\n");
  1400.                 if (attacker.classname == "monster_dog")
  1401.                     bprint (" was mauled by a Rottweiler\n");
  1402.                 if (attacker.classname == "monster_dragon")
  1403.                     bprint (" was fried by a Dragon\n");
  1404.                 if (attacker.classname == "monster_enforcer")
  1405.                     bprint (" was blasted by an Enforcer\n");
  1406.                 if (attacker.classname == "monster_fish")
  1407.                     bprint (" was fed to the Rotfish\n");
  1408.                 if (attacker.classname == "monster_hell_knight")
  1409.                     bprint (" was slain by a Death Knight\n");
  1410.                 if (attacker.classname == "monster_knight")
  1411.                     bprint (" was slashed by a Knight\n");
  1412.                 if (attacker.classname == "monster_ogre")
  1413.                     bprint (" was destroyed by an Ogre\n");
  1414.                 if (attacker.classname == "monster_oldone")
  1415.                     bprint (" became one with Shub-Niggurath\n");
  1416.                 if (attacker.classname == "monster_shalrath")
  1417.                     bprint (" was exploded by a Vore\n");
  1418.                 if (attacker.classname == "monster_shambler")
  1419.                     bprint (" was smashed by a Shambler\n");
  1420.                 if (attacker.classname == "monster_tarbaby")
  1421.                     bprint (" was slimed by a Spawn\n");
  1422.                 if (attacker.classname == "monster_vomit")
  1423.                     bprint (" was vomited on by a Vomitus\n");
  1424.                 if (attacker.classname == "monster_wizard")
  1425.                     bprint (" was scragged by a Scrag\n");
  1426.                 if (attacker.classname == "monster_zombie")
  1427.                     bprint (" joins the Zombies\n");
  1428.  
  1429.                 return;
  1430.             }
  1431.             if (attacker.classname == "explo_box")
  1432.             {
  1433.                 bprint (" blew up\n");
  1434.                 return;
  1435.             }
  1436.             if (attacker.solid == SOLID_BSP && attacker != world)
  1437.             {    
  1438.                 bprint (" was squished\n");
  1439.                 return;
  1440.             }
  1441.             if (targ.deathtype == "falling")
  1442.             {
  1443.                 targ.deathtype = "";
  1444.                 bprint (" fell to his death\n");
  1445.                 return;
  1446.             }
  1447.             if (attacker.classname == "trap_shooter" || attacker.classname == "trap_spikeshooter")
  1448.             {
  1449.                 bprint (" was spiked\n");
  1450.                 return;
  1451.             }
  1452.             if (attacker.classname == "fireball")
  1453.             {
  1454.                 bprint (" ate a lavaball\n");
  1455.                 return;
  1456.             }
  1457.             if (attacker.classname == "trigger_changelevel")
  1458.             {
  1459.                 bprint (" tried to leave\n");
  1460.                 return;
  1461.             }
  1462.  
  1463.             bprint (" died\n");
  1464.         }
  1465.         }
  1466. };
  1467.  
  1468. void () ChasecamNewlevel =
  1469. {
  1470.   if (self.owner.speed & CHASECAM_ON)
  1471.     ChasecamStart (self.owner);
  1472.  
  1473.   if (self.owner.speed & LASER_ON)
  1474.   {
  1475.     self.owner.speed = self.owner.speed - LASER_ON;
  1476.     LaserToggle (self.owner);
  1477.   }
  1478.  
  1479.   remove (self);
  1480. };
  1481.